<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="银行" prop="bankId">
        <el-select
          v-model="queryParams.bankId"
          placeholder="请选择银行"
          style="width: 200px"
          clearable
        >
          <el-option
            v-for="dict in yinhang"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        <el-button type="info" @click="handleAdvancedSearchOpen"
          >高级搜索</el-button
        >
      </el-form-item>
    </el-form>

    <!-- 高级搜索弹窗 -->
    <el-dialog
      title="高级搜索"
      v-model="advancedSearch"
      width="800px"
      append-to-body
    >
      <el-form :model="queryParams" ref="queryRef" label-width="100px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="日期区间" prop="dateRange">
              <el-date-picker
                v-model="dateRange"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                value-format="YYYY-MM-DD"
                :shortcuts="dateShortcuts"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="摘要" prop="abstracts">
              <el-input
                v-model="queryParams.abstracts"
                placeholder="请输入摘要"
                clearable
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收支类别" prop="inoutId">
              <el-select
                v-model="queryParams.inoutId"
                placeholder="请选择收支类别"
                clearable
              >
                <el-option
                  v-for="dict in shouzhi"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="余额" prop="balance">
              <el-input
                v-model="queryParams.balance"
                placeholder="请输入余额"
                clearable
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="往来单位" prop="correspondentId">
              <el-select
                v-model="queryParams.correspondentId"
                placeholder="请选择往来单位"
                clearable
              >
                <el-option
                  v-for="dict in wanglai"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目" prop="itemId">
              <el-select
                v-model="queryParams.itemId"
                placeholder="请选择项目"
                clearable
              >
                <el-option
                  v-for="dict in xiangmu"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="部门" prop="sectionId">
              <el-select
                v-model="queryParams.sectionId"
                placeholder="请选择部门"
                clearable
              >
                <el-option
                  v-for="dict in bumen"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="经手人" prop="personId">
              <el-select
                v-model="queryParams.personId"
                placeholder="请选择经手人"
                clearable
              >
                <el-option
                  v-for="dict in jingshouren"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="关联凭证" prop="proof">
              <el-input
                v-model="queryParams.proof"
                placeholder="请输入关联凭证"
                clearable
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="往来账号" prop="currentAccount">
              <el-input
                v-model="queryParams.currentAccount"
                placeholder="请输入往来账号"
                clearable
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结算方式" prop="settlementId">
              <el-select
                v-model="queryParams.settlementId"
                placeholder="请选择结算方式"
                clearable
              >
                <el-option
                  v-for="dict in fangshi"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="票据号" prop="ticket">
              <el-input
                v-model="queryParams.ticket"
                placeholder="请输入票据号"
                clearable
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input
                v-model="queryParams.remark"
                placeholder="请输入备注"
                clearable
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="交易流水号" prop="tradingStatement">
              <el-input
                v-model="queryParams.tradingStatement"
                placeholder="请输入交易流水号"
                clearable
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="日记账序号" prop="journalSerial">
              <el-input
                v-model="queryParams.journalSerial"
                placeholder="请输入日记账序号"
                clearable
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="handleAdvancedSearch"
            >确定</el-button
          >
          <el-button @click="resetAdvancedSearch">重置</el-button>
          <el-button @click="advancedSearch = false">取消</el-button>
        </div>
      </template>
    </el-dialog>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['system:journal:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:journal:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:journal:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="Upload"
          @click="handleImport"
          v-hasPermi="['system:journal:import']"
          >导入</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['system:journal:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-switch
          v-model="showAll"
          active-text="显示全部"
          @change="handleShowAllChange"
        />
      </el-col>
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="journalList"
      @selection-change="handleSelectionChange"
      :show-summary="true"
      :summary-method="getSummaries"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        label="日期"
        align="center"
        prop="createDate"
        width="180"
      >
        <template #default="scope">
          <span>{{ parseTime(scope.row.createDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="摘要" align="center" prop="abstracts" />
      <el-table-column label="收支类别" align="center" prop="inoutId">
        <template #default="scope">
          <dict-tag :options="shouzhi" :value="scope.row.inoutId" />
        </template>
      </el-table-column>
      <el-table-column label="往来单位" align="center" prop="correspondentId">
        <template #default="scope">
          <dict-tag :options="wanglai" :value="scope.row.correspondentId" />
        </template>
      </el-table-column>
      <el-table-column label="收入" align="center" prop="income" />
      <el-table-column label="支出" align="center" prop="disburse" />
      <el-table-column label="余额" align="center" prop="balance" />
      <el-table-column label="关联凭证" align="center" prop="proof" />
      <el-table-column label="日记账序号" align="center" prop="journalSerial" />

      <!-- 以下列只在显示全部时显示 -->
      <el-table-column v-if="showAll" label="项目" align="center" prop="itemId">
        <template #default="scope">
          <dict-tag :options="xiangmu" :value="scope.row.itemId" />
        </template>
      </el-table-column>
      <el-table-column
        v-if="showAll"
        label="部门"
        align="center"
        prop="sectionId"
      >
        <template #default="scope">
          <dict-tag :options="bumen" :value="scope.row.sectionId" />
        </template>
      </el-table-column>
      <el-table-column
        v-if="showAll"
        label="经手人"
        align="center"
        prop="personId"
      >
        <template #default="scope">
          <dict-tag :options="jingshouren" :value="scope.row.personId" />
        </template>
      </el-table-column>
      <el-table-column
        v-if="showAll"
        label="往来账号"
        align="center"
        prop="currentAccount"
      />
      <el-table-column
        v-if="showAll"
        label="结算方式"
        align="center"
        prop="settlementId"
      >
        <template #default="scope">
          <dict-tag :options="fangshi" :value="scope.row.settlementId" />
        </template>
      </el-table-column>
      <el-table-column
        v-if="showAll"
        label="票据号"
        align="center"
        prop="ticket"
      />
      <el-table-column
        v-if="showAll"
        label="备注"
        align="center"
        prop="remark"
      />
      <el-table-column
        v-if="showAll"
        label="交易流水号"
        align="center"
        prop="tradingStatement"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template #default="scope">
          <el-button
            link
            type="primary"
            icon="Edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:journal:edit']"
            >修改</el-button
          >
          <el-button
            link
            type="primary"
            icon="Delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:journal:remove']"
            >删除</el-button
          >
          <el-button
            link
            type="primary"
            icon="DocumentCopy"
            @click="handleCopy(scope.row)"
            v-hasPermi="['system:journal:add']"
            >复制</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改银行日记账对话框 -->
    <el-dialog :title="title" v-model="open" width="500px" append-to-body>
      <el-form ref="journalRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="日期" prop="createDate">
          <el-date-picker
            clearable
            v-model="form.createDate"
            type="date"
            value-format="YYYY-MM-DD"
            placeholder="请选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="摘要" prop="abstracts">
          <el-input v-model="form.abstracts" placeholder="请输入摘要" />
        </el-form-item>
        <el-form-item label="收支类别" prop="inoutId">
          <el-select v-model="form.inoutId" placeholder="请选择收支类别">
            <el-option
              v-for="dict in shouzhi"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="收入" prop="income">
          <el-input v-model="form.income" placeholder="请输入收入" />
        </el-form-item>
        <el-form-item label="支出" prop="disburse">
          <el-input v-model="form.disburse" placeholder="请输入支出" />
        </el-form-item>
        <el-form-item label="往来单位" prop="correspondentId">
          <el-select
            v-model="form.correspondentId"
            placeholder="请选择往来单位"
          >
            <el-option
              v-for="dict in wanglai"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="项目" prop="itemId">
          <el-select v-model="form.itemId" placeholder="请选择项目">
            <el-option
              v-for="dict in xiangmu"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="部门" prop="sectionId">
          <el-select v-model="form.sectionId" placeholder="请选择部门">
            <el-option
              v-for="dict in bumen"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="经手人" prop="personId">
          <el-select v-model="form.personId" placeholder="请选择经手人">
            <el-option
              v-for="dict in jingshouren"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="关联凭证" prop="proof">
          <el-input v-model="form.proof" placeholder="请输入关联凭证" />
        </el-form-item>
        <el-form-item label="往来账号" prop="currentAccount">
          <el-input
            v-model="form.currentAccount"
            placeholder="请输入往来账号"
          />
        </el-form-item>
        <el-form-item label="结算方式" prop="settlementId">
          <el-select v-model="form.settlementId" placeholder="请选择结算方式">
            <el-option
              v-for="dict in fangshi"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="票据号" prop="ticket">
          <el-input v-model="form.ticket" placeholder="请输入票据号" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="交易流水号" prop="tradingStatement">
          <el-input
            v-model="form.tradingStatement"
            placeholder="请输入交易流水号"
          />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 添加导入对话框 -->
    <el-dialog
      :title="upload.title"
      v-model="upload.open"
      width="400px"
      append-to-body
    >
      <el-upload
        ref="uploadRef"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <el-icon class="el-icon--upload"><upload-filled /></el-icon>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <template #tip>
          <div class="el-upload__tip text-center">
            <div class="el-upload__tip">
              <el-checkbox
                v-model="upload.updateSupport"
              />是否更新已经存在的数据
            </div>
            <span>仅允许导入xlsx、xls格式文件。</span>
            <el-link
              type="primary"
              :underline="false"
              style="font-size: 12px; vertical-align: baseline"
              @click="importTemplate"
              >下载模板</el-link
            >
          </div>
        </template>
      </el-upload>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitFileForm">确 定</el-button>
          <el-button @click="upload.open = false">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Journal">
import {
  listJournal,
  getJournal,
  delJournal,
  addJournal,
  updateJournal,
} from "@/api/system/journal";
import { getToken } from "@/utils/auth";

const { proxy } = getCurrentInstance();
const { shouzhi, xiangmu, wanglai, fangshi, bumen, yinhang, jingshouren } =
  proxy.useDict(
    "shouzhi",
    "xiangmu",
    "wanglai",
    "fangshi",
    "bumen",
    "yinhang",
    "jingshouren"
  );

const journalList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const advancedSearch = ref(false);
const showAll = ref(true);

// 修改日期区间变量的初始值为当天
const dateRange = ref(() => {
  const today = new Date().toISOString().slice(0, 10);
  return [today, today];
});

// 添加日期快捷选项
const dateShortcuts = [
  {
    text: "最近一周",
    value: () => {
      const end = new Date();
      const start = new Date();
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
      return [start, end];
    },
  },
  {
    text: "最近一个月",
    value: () => {
      const end = new Date();
      const start = new Date();
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
      return [start, end];
    },
  },
  {
    text: "最近三个月",
    value: () => {
      const end = new Date();
      const start = new Date();
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
      return [start, end];
    },
  },
];

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    bankId: null,
    beginCreateDate: new Date().toISOString().slice(0, 10), // 设置开始日期为当天
    endCreateDate: new Date().toISOString().slice(0, 10), // 设置结束日期为当天
    abstracts: null,
    inoutId: null,
    income: null,
    disburse: null,
    balance: null,
    correspondentId: null,
    itemId: null,
    sectionId: null,
    personId: null,
    proof: null,
    currentAccount: null,
    settlementId: null,
    ticket: null,
    remark: null,
    tradingStatement: null,
    journalSerial: null,
  },
  rules: {
    createDate: [{ required: true, message: "日期不能为空", trigger: "blur" }],
    abstracts: [{ required: true, message: "摘要不能为空", trigger: "blur" }],
    inoutId: [
      { required: true, message: "收支类别不能为空", trigger: "change" },
    ],
  },
});

const { queryParams, form, rules } = toRefs(data);

// 添加上传相关变量
const upload = reactive({
  open: false,
  title: "",
  isUploading: false,
  updateSupport: false,
  url: import.meta.env.VITE_APP_BASE_API + "/system/journal/importData",
  headers: { Authorization: "Bearer " + getToken() },
});

const uploadRef = ref(null);

/** 查询银行日记账列表 */
function getList() {
  loading.value = true;
  // 如果没有选择银行且字典数据已加载，则默认选择第一个银行
  if (!queryParams.value.bankId && yinhang.value?.length > 0) {
    queryParams.value.bankId = yinhang.value[0].value;
  }
  listJournal(queryParams.value).then((response) => {
    journalList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}

// 监听银行字典数据变化
watch(
  yinhang,
  (newVal) => {
    if (newVal?.length > 0 && !queryParams.value.bankId) {
      queryParams.value.bankId = newVal[0].value;
      getList();
    }
  },
  { immediate: true }
);

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    bankId: null,
    createDate: null,
    abstracts: null,
    inoutId: null,
    income: null,
    disburse: null,
    balance: null,
    correspondentId: null,
    itemId: null,
    sectionId: null,
    personId: null,
    proof: null,
    currentAccount: null,
    settlementId: null,
    ticket: null,
    remark: null,
    tradingStatement: null,
    journalSerial: null,
  };
  proxy.resetForm("journalRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  // 设置当前日期
  form.value.createDate = new Date().toISOString().slice(0, 10); // 格式化为 YYYY-MM-DD
  open.value = true;
  title.value = "添加银行日记账";
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _id = row.id || ids.value;
  getJournal(_id).then((response) => {
    form.value = response.data;
    open.value = true;
    title.value = "修改银行日记账";
  });
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["journalRef"].validate((valid) => {
    if (valid) {
      if (form.value.id != null) {
        updateJournal(form.value).then((response) => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        addJournal(form.value).then((response) => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value;
  proxy.$modal
    .confirm('是否确认删除银行日记账编号为"' + _ids + '"的数据项？')
    .then(function () {
      return delJournal(_ids);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => {});
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "system/journal/export",
    {
      ...queryParams.value,
    },
    `journal_${new Date().getTime()}.xlsx`
  );
}

/** 高级搜索相关的方法 */
function handleAdvancedSearch() {
  if (dateRange.value) {
    queryParams.value.beginCreateDate = dateRange.value[0];
    queryParams.value.endCreateDate = dateRange.value[1];
  } else {
    queryParams.value.beginCreateDate = undefined;
    queryParams.value.endCreateDate = undefined;
  }
  handleQuery();
  advancedSearch.value = false;
}

// 修改重置方法，重置时将日期设置为当天
function resetAdvancedSearch() {
  const today = new Date().toISOString().slice(0, 10);
  dateRange.value = [today, today];
  queryParams.value.beginCreateDate = today;
  queryParams.value.endCreateDate = today;
  proxy.resetForm("queryRef");
  handleQuery();
}

/** 导入按钮操作 */
function handleImport() {
  upload.title = "银行日记账数据导入";
  upload.open = true;
}

/** 下载模板操作 */
function importTemplate() {
  proxy.download(
    "system/journal/importTemplate",
    {},
    `journal_template_${new Date().getTime()}.xlsx`
  );
}

/** 文件上传中处理 */
function handleFileUploadProgress(event, file, fileList) {
  upload.isUploading = true;
}

/** 文件上传成功处理 */
function handleFileSuccess(response, file, fileList) {
  upload.open = false;
  upload.isUploading = false;
  uploadRef.value.clearFiles();
  proxy.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  getList();
}

/** 提交上传文件 */
function submitFileForm() {
  uploadRef.value.submit();
}

/** 添加显示全部切换处理函数 */
function handleShowAllChange(value) {
  showAll.value = value;
}

/** 表格合计行计算方法 */
function getSummaries(param) {
  const { columns, data } = param;
  const sums = [];
  columns.forEach((column, index) => {
    if (index === 0) {
      sums[index] = "";
      return;
    }
    // 摘要列显示"合计"
    if (column.property === "abstracts") {
      sums[index] = "合计";
      return;
    }
    // 计算收入合计
    if (column.property === "income") {
      const values = data.map((item) => Number(item.income) || 0);
      sums[index] = values
        .reduce((prev, curr) => {
          return prev + curr;
        }, 0)
        .toFixed(2);
      return;
    }
    // 计算支出合计
    if (column.property === "disburse") {
      const values = data.map((item) => Number(item.disburse) || 0);
      sums[index] = values
        .reduce((prev, curr) => {
          return prev + curr;
        }, 0)
        .toFixed(2);
      return;
    }
    // 显示最后一条记录的余额
    if (column.property === "balance" && data.length > 0) {
      sums[index] = data[data.length - 1].balance;
      return;
    }
    sums[index] = "";
  });
  return sums;
}

/** 打开高级搜索对话框 */
function handleAdvancedSearchOpen() {
  // 设置日期区间为查询参数中的值
  dateRange.value = [
    queryParams.value.beginCreateDate,
    queryParams.value.endCreateDate,
  ];
  advancedSearch.value = true;
}

/** 复制按钮操作 */
function handleCopy(row) {
  reset();
  // 复制行数据，但不包含id和日记账序号
  const copyData = {
    ...row,
    id: null,
    journalSerial: null,
    createDate: new Date().toISOString().slice(0, 10), // 设置为当前日期
  };
  form.value = copyData;
  open.value = true;
  title.value = "复制银行日记账";
}

getList();
</script>

<style scoped>
.el-row {
  margin-bottom: 20px;
}
</style>
